﻿var $url = '/content';

var data = {
    apiUrl: utils.getQueryString('apiUrl'),
    siteId: utils.getQueryString('siteId'),
    id: utils.getQueryString("id"),
    channel: utils.getQueryString('channel'),
    title: utils.getQueryString('title'),
    pageLoad: false,
    contents: []
};

var methods = {
    
    loadPage: function () {
        var $this = this;
        $url = $url + "/" + this.id + "/enrollments" 

        $api.get($url).then(function (response) {
            //获取报名
            $this.pageLoad = true;
            $this.contents = response.data;
        });
    },

    btnDeleteClick: function (id, index) {
        var $this = this;

        utils.alertDelete({
            title: '取消报名',
            text: '此操作将删除当前报名，确定吗？',
            callback: function () {
                utils.loading(true);
                $api.post("/enrollment/delete/" + id).then(function (response) {
                    $this.contents.splice(index, 1);
                }).catch(function (error) {

                }).then(function () {
                    parent.location.reload(true);
                    utils.loading(false);
                });
            }
        });

    }
};

var $vue = new Vue({
    el: '#main',
    data: data,
    methods: methods,
    computed: {
        getGender: function (idcard) {
            return utils.IdCard(idcard, 2);
        }
    },
    created: function () {
        this.loadPage();
    }
});